//! # MiniLib  
//! 小型工具库，恐咖兵糖常用工具的集合  
//! Common Tools for 恐咖兵糖  
//! Gitee [https://gitee.com/kkbt/rust-kkbt](https://gitee.com/kkbt/rust-kkbt)  
//! Author: 恐咖兵糖 [主页](https://www.ftls.xyz) Mail: snowandocean@foxmail.com   

mod skv;
pub use skv::*;
use std::io::prelude::*;

/// 传入文件 path 打印 hex (print file hex)  
///
/// in: file path 显示行数
/// fun: print 16xn hex  
/// 传入文件 path 打印 hex   
pub fn show_file_hex(path: &str, show_lines: i32) -> std::io::Result<()> {
    let mut f = std::fs::File::open(path)?;
    let mut buffer = [0; 16];
    for _ in 0..show_lines {
        // 读取文件中的16个字节
        let n = f.read(&mut buffer[..])?;
        print!("{:02x?} ", &buffer[..n]);
        println!("{:03?}", &buffer[..n]);
        if n < 16 {
            break;
        }
    }
    Ok(())
}
